$(function() {
		$(".dian").click(function() {
			var id = $(this).children("#yin1").val();
			window.location.href = "mcfour.jsp?spid=" + id;
		})
		$(".yin").hide();
		$(".div_5").mouseenter(function() {
			$(this).children(".yin").slideDown(100);
		})
		$(".div_5").mouseleave(function() {
			$(this).children(".yin").slideUp(100);
		})
	})


	


	var cai = 0;
	function GetQueryString(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
		var r = window.location.search.substr(1).match(reg);
		if (r != null) return (r[2]);
		return null;
	}

	var sname = GetQueryString("spid");
	if (sname != null) {
		var sname_ = decodeURIComponent(sname);
		cai = sname;
	}
	
	function uploadPic() {  
		var  name = $("#name").val();
	
		var current = $("#file").val();
        // 上传设置  
        var options = {  
                // 规定把请求发送到那个URL  
                url: "mcthrees.do?pan=jia",  
                // 请求方式  
                type: "post",  
                data:{"name":name,"spid":cai},
                // 服务器响应的数据类型  
                dataType: "json",  
                // 请求成功时执行的回调函数  
                success: function(data, status, xhr) {  
                    // 图片显示地址  
                    var zui = "<div class='div_5'>"
			    		+"<div class='yin' style='display:none'>"
			    			+"<div><a href='#'>编辑</a></div>"
			    			+"<div><a href='javascript:void(0);' onclick='del(this,"+data.id+")'>删除</a></div>"
			    		+"</div>"
			    		+"<div class='dian'>"
			    		+"<input type='hidden' id='yin1' value='"+data.id+"' />"
			            +"<img src='"+data.img+"' width='35px' height='35px'>"
			            +"<br>"
			           +"<p>"+data.name+"</p>"
			           +"</div>"
			        +"</div>";
		
                    $("#ding").prepend(zui);
                }  
        };  
          
        $("#jvForm").ajaxSubmit(options);  
        
        $(".dian").click(function() {
			var id = $(this).children("#yin1").val();
			window.location.href = "mcfour.jsp?spid=" + id;
		})
		$(".yin").hide();
		$(".div_5").mouseenter(function() {
			$(this).children(".yin").slideDown(100);
		})
		$(".div_5").mouseleave(function() {
			$(this).children(".yin").slideUp(100);
		})
    }  
	
	
	
	function del(name,id){
		
			
  		swal({ 
		  title: "确定删除吗？", 
		  text: "你将无法恢复该虚拟文件！", 
		  type: "warning",
		  showCancelButton: true, 
		  confirmButtonColor: "#DD6B55",
		  confirmButtonText: "确定删除！", 
		  cancelButtonText: "取消删除！",
		  closeOnConfirm: false, 
		  closeOnCancel: false	
		},
		function(isConfirm){ 
		  if (isConfirm) { 
		  
		  	
		  		$.post("mcthrees.do?pan=del", {
			"id" : id
		}, function(date) {
			if (date == 1) {
				$(name).parent().parent().parent().remove();
			}
		})
		    swal("删除！", "你的虚拟文件已经被删除。",
			"success"); 
		  } else { 
		    swal("取消！", "你的虚拟文件是安全的:)",
			"error"); 
		  } 
		});
		
		
	}